package com.fmjava.service.Impl;

import com.fmjava.domain.Employee;
import com.fmjava.domain.PageListResult;
import com.fmjava.mapper.EmployeeMapper;
import com.fmjava.service.EmployeeService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Component
@Transactional/*提交事务*/
public class EmployeeServiceImpl implements EmployeeService {
    @Autowired
    private EmployeeMapper employeeMapper;
    @Override
    public PageListResult getAllEmployee() {

        Page<Object> objects = PageHelper.startPage(1, 5);//分页插件
        List<Employee> employees = employeeMapper.selectAll();
        System.out.println(employees);
        PageListResult pageListResult = new PageListResult();//自己设置的分页模型
        pageListResult.setTotal(objects.getTotal());
        pageListResult.setRows(employees);
        System.out.println("aaa");
        return pageListResult;
    }
}
